<template>
  <div class="container">
    <topTitle :titleText="titleText"></topTitle>
    <div class="mainCon">
      <ImproveProgress
        v-if="pageType === 'improve'"
        :active="active"
        style="padding-top: 20px"
      ></ImproveProgress>
      <div class="spacing" v-if="pageType === 'improve'"></div>
      <component
        :is="currentComponent"
        :uscc="uscc"
        :pageType="pageType"
        @changeActive="changeActive"
      ></component>
    </div>
  </div>
</template>
<script>
import ImproveProgress from './ImproveProgress'
import ImproveBasicInfo from './ImproveBasicInfo'
import ImproveAttachmentInfo from './ImproveAttachmentInfo'

export default {
  name: 'ImproveInformation',
  components: {
    ImproveProgress,
    ImproveBasicInfo,
    ImproveAttachmentInfo,
  },
  data() {
    return {
      titleText: '', //"完善档案信息"/"编辑档案信息"
      pageType: '', //单位完善improve监察编辑edit
      active: 0, //进度条
      currentComponent: '',
      uscc: '',
    }
  },
  // beforeRouteEnter(to,from,next){
  //     if(from.path==="/home/indexHome/companyHome"){
  //         next((vm) => {
  //             vm.titleText = "完善档案信息";
  //             vm.pageType = "improve";
  //         });
  //     }else{
  //         next((vm) => {
  //             vm.titleText = "编辑档案信息";
  //             vm.pageType = "edit";
  //         });
  //     }
  // },
  created() {
    this.pageType = this.$route.query.pageType
    this.uscc = this.$route.query.uscc
    this.titleText =
      this.pageType === 'improve' ? '完善档案信息' : '编辑档案信息'
    if (this.active === 0) {
      this.currentComponent = 'ImproveBasicInfo'
    } else {
      this.currentComponent = 'ImproveAttachmentInfo'
    }
  },
  watch: {
    active() {
      if (this.active === 0) {
        this.currentComponent = 'ImproveBasicInfo'
      } else {
        this.currentComponent = 'ImproveAttachmentInfo'
      }
    },
  },
  methods: {
    changeActive(val) {
      this.active = val
    },
  },
}
</script>
<style scoped lang="less">
.mainCon {
  padding: 0 0 24px 0;
}
</style>
